<% content_for :css do %>
  <%= stylesheet_link_tag 'tools_zhui_tian_ya_hot_posts_show' %>
<% end %>
<% content_for :javascript do %>
<script type="text/javascript" charset="utf-8">
  function go_to(page_num)
  {
    $('page').value = page_num;
    $('search_form').submit();
  }
  
  function hl_lz()
  {
    $$('div.lz').each(function(lz_post) {
      lz_post.className = 'hot_post lz hl';      
    });
    $('hl_lz').hide();
    $('ll_lz').show();
  }
  
  function ll_lz()
  {
    $$('div.lz').each(function(lz_post) {
      lz_post.className = 'hot_post lz';      
    });
    $('ll_lz').hide();
    $('hl_lz').show();
  }
  
  setValue('scope','<%= @follow_setting.scope %>');
  
  // tian_ya 僵尸
  function ResetImageSize(obj,width) 
  {
    var image=new Image();
		image.src=e.src;
		var w=image.width;
		var h=image.height;
		if(w>mWidth)
		{
			e.width=mWidth;
			e.height=h*mWidth/w;
		}    
  }
</script>
<% end %>  
<div id="hot_post">
  <div id="head">
    <div class="my_tools corner">
      <div class='logo'>
        
      </div>
      <div class="left">   
        <div class='tools'>          
          <% if @follow_setting.scope.lz? %>
            <%= link_to '看全部贴', tools_zhui_tian_ya_hot_post_url(@hot_post, :scope => 'all')  %>
          <% else %>             
            <%= link_to '只看楼主', tools_zhui_tian_ya_hot_post_url(@hot_post, :scope => 'lz')  %>
          <% end %>          
          <%= link_to_remote '高亮楼主',
                :url => high_or_low_light_lz_tools_zhui_tian_ya_hot_post_url(@hot_post),
                :method => :put,
                :loading => 'hl_lz()',
                :html => {
                  :id => :hl_lz ,
                  :style => @follow_setting.lz_show_status.high_light? ? 'display:none' : ''
                }
          %>
          <%= link_to_remote '低亮楼主',
                :url => high_or_low_light_lz_tools_zhui_tian_ya_hot_post_url(@hot_post),
                :method => :put,
                :loading => 'll_lz()',
                :html => {
                  :id => :ll_lz ,
                  :style => @follow_setting.lz_show_status.high_light? ? '' : 'display:none'
                }
          %>
          <%= link_to_remote '【追此帖】',
                :update => :setting,
                :url => edit_zhui_tools_zhui_tian_ya_hot_post_url(@hot_post),
                :method => :get,
                :loading => nano_loading('zhui',:only_img => true),
                :complete => "$('zhui').hide()",
                :html => {
                  :class => :zhui,
                  :id => :zhui,
                  :style => @follow_setting.status.give_up? ? '' : 'display:none'
                } %>
          <%= link_to '原帖',@hot_post.first_page_url, :target => :_blank  %>
          <%= link_to '我追', new_tools_zhui_tian_ya_hot_post_url , :target => :_blank, :title => '我来带头追个贴' %>
          <%= link_to '返回追天涯<<', tools_zhui_tian_ya_hot_posts_url , :class => :go_back %>
        </div>
        <div id='setting' class='setting corner'>
          <%= render :file => 'tools/zhui_tian_ya_hot_posts/show_zhui.js' %>          
        </div>
      </div>
      <div title="我已经阅读了<%= number_with_precision @follow_setting.read_schedule_percent, :precision => 2 %>%" class="read_schedule">
        <div class="tip">
          阅读进度：  
        </div>
        <div class="unread">
          <div style="width: <%= @follow_setting.read_schedule_ratio * 30 %>px;" class="read"></div>
        </div>
      </div>
    </div>
    <div id="title">
      <b>『<%= @hot_post.hot_post_type.name %>』</b><%= @hot_post.title %>
    </div>
  </div>
  <div id='hp_body'>      
    <%= render :file => 'tools/zhui_tian_ya_hot_posts/show.js' %>   
  </div>
</div>
<% form_tag tools_zhui_tian_ya_hot_post_url(@hot_post), :method => :get, :id => 'search_form'  do %>
  <%= hidden_field_tag :page, params[:page] %>  
  <%= hidden_field_tag :read_sub_hot_post_id %> 
<% end %>
<% if has_logined_by_user? %>
<script type="text/javascript" charset="utf-8">
  window.onscroll= function () {
    $('debugger').update('');
    var index = 1;
    var last_one = $$('div#hot_posts div.hot_post').first;
    $$('div#hot_posts div.hot_post').each(function(hot_post) {      
      var p = Position.page(hot_post);
      if((p[1] - 280) <= 0) {
        last_one = hot_post;
      } 
    });
    
    if(last_one.id != undefined) {
      $('read_sub_hot_post_id').value = last_one.id.split('hot_post_')[1];     
    }    
    debug(last_one.id + ' -- ' + $F('read_sub_hot_post_id'));
  }
</script>
<%= observe_field :read_sub_hot_post_id,
      :frequency => 10,
      :url => read_tools_zhui_tian_ya_hot_post_url(@hot_post),
      :with => "Form.serialize('search_form')",
      :method => :put
 %>
<% end %>
<% if @follow_setting.read_sub_hot_post.present? %>
<script type="text/javascript" charset="utf-8">
  if($('hot_post_<%= @follow_setting.read_sub_hot_post.id %>') != null) {
    Effect.ScrollTo('hot_post_<%= @follow_setting.read_sub_hot_post.id %>',{ during:3 }); 
  }  
</script>
<% end %>